package com.example.exam.service.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.exam.entity.Path;
import com.example.exam.mapper.PathMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FileServiceImpl implements FileService {
    @Autowired
    private PathMapper pathMapper;
    @Override
    public String getPath(String name){
        QueryWrapper<Path> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", name);
        Path path = pathMapper.selectOne(queryWrapper);
        return path == null ? null : path.getPath();
    }

    @Override
    public Integer pushPath(Path path){
        return pathMapper.insert(path)  > 0 ? 1 : 0;
    }

    @Override
    public Integer pushFile(MultipartFile file, String filename) {
        return null;
    }
}
